#ifndef PLAYER_KERNEL_IFACE_H
#define PLAYER_KERNEL_IFACE_H

#define PLAYER_KERNEL_MAIN_REGISTER		0xFF12
#define KERNEL_IFACE_MAX_FILES			27


#include <typedefs.h>
#include <fs.h>


typedef void PKERNEL_CALL_BACK( UINT32 iface_tag, UINT32 data, UINT32 status );


// iface_tag
enum {								// kernel params
	PLAYER_CMD_NULL = 0,
	
	PLAYER_CMD_BEGIN,
	// init player's cover. In call back function use data as pointer to PLAYER_DATA_T
	PLAYER_CMD_DATA_REQ = PLAYER_CMD_BEGIN,	// call_back
	
	// play track
	PLAYER_CMD_PLAY,				// value
	// pause/unpause current track
	PLAYER_CMD_PAUSE,				// NULL
	// Stop playing and close media file
	PLAYER_CMD_STOP,				// NULL
	
	PLAYER_CMD_NEXT_TRACK,			// NULL
	
	PLAYER_CMD_PREV_TRACK,			// NULL
	
	// Try to play track by fid
	PLAYER_CMD_PLAY_FILE,			// files[0]
	// Play file in new playlist
	PLAYER_CMD_PLAY_NEW,			// files, num, value
	
	// PLAYLIST CMDs
	
	PLAYER_CMD_PL_ADD,				// files, num
	// Add to playlist and play
	PLAYER_CMD_PL_ADD_AND_PLAY,		// files, num, value
	// delete tracks from playlist
	PLAYER_CMD_PL_DELETE,			// value, num
	// clear playlist
	PLAYER_CMD_PL_CLEAR,			// NULL
	// ... and stop, reset player
	PLAYER_CMD_PL_CLEAR_AND_STOP,	// NULL
	// delete missed tracks
	PLAYER_CMD_PL_REPAIR,			// NULL
	
	PLAYER_CMD_SEEK,				// value in ms
	
	PLAYER_CMD_END
};

#define PLAYER_CMD_NUM				PLAYER_CMD_END - PLAYER_CMD_BEGIN

typedef struct {
	UINT32				version;
	UINT32				tag;		// PLAYER_CMD_*
	PKERNEL_CALL_BACK *	call_back;
	UINT32				value;
	UINT32				num;			// number of tracks if field 'files'
	UINT32				reserved[3];
	
	FILE_ID				files[KERNEL_IFACE_MAX_FILES];
} PLAYER_IFACE_T;	// maxsize = 0xFB = 251

#define piface(event_data)				((PLAYER_IFACE_T *)(event_data))


enum {	// PLAYER_DATA_T::state
	PLAYER_STATE_NULL = 0,
	PLAYER_STATE_STOP = PLAYER_STATE_NULL,
	PLAYER_STATE_PAUSE,
	PLAYER_STATE_PLAY,
	PLAYER_STATE_OPEN,
	PLAYER_STATE_ERROR
};

#define PARAM_BIT_SHUFFLE			1 << 0
#define PARAM_BIT_REPEAT_ONE		1 << 1
#define PARAM_BIT_AUTO_NEXT			1 << 2
#define PARAM_BIT_FREE_3			1 << 3
#define PARAM_BIT_FREE_4			1 << 4
#define PARAM_BIT_FREE_5			1 << 5
#define PARAM_BIT_FREE_6			1 << 6
#define PARAM_BIT_FREE_7			1 << 7
#define PARAM_BIT_FREE_8			1 << 8

typedef struct {
	UINT32					cur;			// current track
	UINT32					num;			// number of tracks
	UINT32					state;			// player's state
	UINT32					params;			// bit params
	MME_GC_MEDIA_FILE		media_file;		// opened mme file
	FILE_ID *				play_list;		// playlist
} PLAYER_DATA_T;




#define PLAYER_IFACE_VERSION			(0x00000100 | PLAYER_CMD_NUM)

#endif
